<?php
/**
 * RabbitCMS
 * 
 * LICENSE
 *
 * This source file is subject to the GNU GENERAL PUBLIC LICENSE Version 2 
 * that is bundled with this package in the file LICENSE.txt.
 * It is also available through the world-wide-web at this URL:
 * http://www.gnu.org/licenses/gpl-2.0.txt
 * If you did not receive a copy of the license and are unable to
 * obtain it through the world-wide-web, please send an email
 * to license@tomatocms.com so we can send you a copy immediately.
 * 
 * @copyright	Copyright (c) 2009-2010 TIG Corporation (http://www.tig.vn)
 * @license		http://www.gnu.org/licenses/gpl-2.0.txt GNU GENERAL PUBLIC LICENSE Version 2
 * @version 	$Id: show.phtml 5399 2010-09-12 17:49:50Z huuphuoc $
 * @since		2.0.9
 */
?>
<?php
$count = count($this->categories);
$rightStack = array();
?>

<div id="categories" class="white-box">
    <div class="box-title"><h3><?php echo $this->translate()->widget('title')?></h3></div>
    
    <ul>
    <?php
    if($count > 0){
        for ($i = 0; $i < $count; $i++) {
            while (count($rightStack) > 0 && $rightStack[count($rightStack) - 1] < $this->categories[$i]->rht) {
                array_pop($rightStack);
            }
    ?>
        <li id="category-<?php echo $this->categories[$i]->id ?>" <?php if ($i == $count - 1) echo 'class="last"'; ?>>
            <a  href="<?php echo $this->url($this->categories[$i]->getProperties(), 'product_product_category')?>">
                <?php echo $this->categories[$i]->name?>
            </a>
        </li>
    <?php
            $rightStack[] = $this->categories[$i]->rht;
        }
    }                          
?>
    </ul>
</div>
